//
//  GeneralDefine.swift
//  BuildOnline
//
//  Created by ywy on 2018/3/1.
//  Copyright © 2018年 Wely. All rights reserved.
//

import Foundation
import UIKit


let SCREEN_HEIGHT = UIScreen.main.bounds.height
let SCREEN_width  = UIScreen.main.bounds.width
// 状态栏高度
let StatusHeight = UIApplication.shared.statusBarFrame.size.height
let NavHeight = 44
let TopHeight = StatusHeight + CGFloat(NavHeight)
// iphone X 安全区域高度
let  SafeAreaHeight = Int(StatusHeight) > 20 ?34:0

let topAreHeight  = Int(StatusHeight) > 20 ? 15 : 10
// 底部高度
let BottomHeight = 49 + CGFloat (SafeAreaHeight)

func ZCGRECT (x:CGFloat, y:CGFloat, width:CGFloat, height:CGFloat) -> CGRect{
    return CGRect(x: x, y: y, width: width, height: height)
}

#if DEBUG


#else



#endif




//RGBA(r: 236, g: 235, b: 235, a: 1) 背景灰色
func RGBA (r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat) -> UIColor{
    
    return UIColor (red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a)
}

let userDefaults =  UserDefaults.standard

// 注册通知
func ADD_OBSERVER(target: Any, selector: Selector, name: NSNotification.Name, obj: Any?) -> Void {
    NotificationCenter.default.addObserver(target, selector: selector, name: name, object: obj)
}
// 发送通知
func POST_NOTIFICATION(notificationName: NSNotification.Name, obj: Any?, userInfo:  [AnyHashable : Any]?) -> Void {
    NotificationCenter.default.post(name: notificationName, object: obj, userInfo: userInfo)
}
// 移除所有通知
func REMOVE_ALL_OBSERVER(id: Any) -> Void {
    NotificationCenter.default.removeObserver(id)
}

//移除指定通知
func REMOVE_OBSERVER(id: Any, name: NSNotification.Name, obj: Any?) -> Void {
    NotificationCenter.default.removeObserver(id, name: name, object: obj)
}
func vTopFromView(view: UIView) -> CGFloat {
    return view.frame.origin.y
}
func vLeftFromView(view: UIView) -> CGFloat {
    return view.frame.origin.x
}
func vBottomFromView(view: UIView) -> CGFloat {
    return view.frame.size.height + view.frame.origin.y
}
func vRightFromView(view: UIView) -> CGFloat {
    return view.frame.size.width + view.frame.origin.x
}
